<template>
  <div class="addbody">
<van-cell-group style="width:355px; height:44px;">
  <van-field v-model="value"  placeholder="请输入商品名称" />
</van-cell-group>
<van-button  type="info" text="添加商品" loading-text="加载中...." @click="addGoods" class="addbutton" />
  </div>
</template>
<script>
export default {
  props: [],
  data () {
    return {
      value: ''
    }
  },
  mounted () {
  },
  computed: {},
  methods: {
    async addGoods () {
      const val = this.value.trim()
      if (!val) return this.$notify({ type: 'warning', message: '请输入商品名称' })
      const { data: res } = await this.$http.post('/api/addproduct/', { name: this.value })
      console.log(res)
      if (res.status === 0) return this.$notify({ type: 'success', message: '添加成功' })
    }
  }
}
</script>
<style lang="less" scoped>
.addbody {
    box-sizing: border-box;
    width:375px;
    height:164px;
    padding:0 10px;
    .addbutton {
    width: 355px;
    height: 40px;
    margin: 40px 0;
}
}

</style>
